package com.deyuanyun.pic.ctrl.controller.vo.exinsp;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.ctrl.domain.EqptCptestStation;
import com.deyuanyun.pic.ctrl.domain.ExinspPcmAcvg;
import com.deyuanyun.pic.ctrl.service.EQPTBaseService;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * PCM、ACVG测试记录表
 */
public class ExinspPcmAcvgVO extends ExinspBaseVO<ExinspPcmAcvg> {

    // 管道名称
    private String pipeLineName;
    // 测试桩编号
    private String testStationNum;
    // 监测点编号（一个顺序数字而已）
    private String detectionPointNumber;
    // 防腐层漏损点编号PIC_CTRL_EXINSP_OCLPOINT.ID_
    private String oclpointNum;
    // 绝对距离
    private BigDecimal mileage;
    // 现场测试绝对距离（m）
    private BigDecimal fieldTestAbsoluteDistance;
    // 相对测试桩的距离（m）
    private BigDecimal relativeTestPileDistance;
    // 电流（mA）
    public Long electricCurrent;
    // 埋深（m）
    private BigDecimal buriedDepth;
    // dB值
    public Long dbValue;
    // 检测日期
    private String testingDate;
    // 检测单位
    private String testingCompany;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getTestStationNum() {
        return testStationNum;
    }

    public void setTestStationNum(String testStationNum) {
        this.testStationNum = testStationNum;
    }

    public String getDetectionPointNumber() {
        return detectionPointNumber;
    }

    public void setDetectionPointNumber(String detectionPointNumber) {
        this.detectionPointNumber = detectionPointNumber;
    }

    public String getOclpointNum() {
        return oclpointNum;
    }

    public void setOclpointNum(String oclpointNum) {
        this.oclpointNum = oclpointNum;
    }

    public BigDecimal getMileage() {
        return mileage;
    }

    public void setMileage(BigDecimal mileage) {
        this.mileage = mileage;
    }

    public BigDecimal getFieldTestAbsoluteDistance() {
        return fieldTestAbsoluteDistance;
    }

    public void setFieldTestAbsoluteDistance(BigDecimal fieldTestAbsoluteDistance) {
        this.fieldTestAbsoluteDistance = fieldTestAbsoluteDistance;
    }

    public BigDecimal getRelativeTestPileDistance() {
        return relativeTestPileDistance;
    }

    public void setRelativeTestPileDistance(BigDecimal relativeTestPileDistance) {
        this.relativeTestPileDistance = relativeTestPileDistance;
    }

    public Long getElectricCurrent() {
        return electricCurrent;
    }

    public void setElectricCurrent(Long electricCurrent) {
        this.electricCurrent = electricCurrent;
    }

    public BigDecimal getBuriedDepth() {
        return buriedDepth;
    }

    public void setBuriedDepth(BigDecimal buriedDepth) {
        this.buriedDepth = buriedDepth;
    }

    public Long getDbValue() {
        return dbValue;
    }

    public void setDbValue(Long dbValue) {
        this.dbValue = dbValue;
    }

    public String getTestingDate() {
        return testingDate;
    }

    public void setTestingDate(String testingDate) {
        this.testingDate = testingDate;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    EQPTBaseService eqptBaseService = SpringAppliction.getBean(EQPTBaseService.class);

    public void fromDomain(ExinspPcmAcvg domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 测试桩编号
        EqptCptestStation eqptCptestStation = eqptBaseService.queryObjectByPrimaryKey(EqptCptestStation.class, domain.getTestStationId());
        this.testStationNum = eqptCptestStation.getCustomNumber();
        // 监测点编号（一个顺序数字而已）
        this.detectionPointNumber = domain.getDetectionPointNumber();
        // 防腐层漏损点编号PIC_CTRL_EXINSP_OCLPOINT.ID_
        this.oclpointNum = domain.getOclpointId();
        // 绝对距离
        this.mileage = NumberUtil.toMeter(domain.getMileage());
        // 现场测试绝对距离（m）
        this.fieldTestAbsoluteDistance = domain.getFieldTestAbsoluteDistance();
        // 相对测试桩的距离（m）
        this.relativeTestPileDistance = domain.getRelativeTestPileDistance();
        // 电流（mA）
        this.electricCurrent = domain.getElectricCurrent();
        // 埋深（m）
        this.buriedDepth = domain.getBuriedDepth();
        // dB值
        this.dbValue = domain.getDbValue();
        // 检测日期
        this.testingDate = DateFormat.format(domain.getTestingDate());
        // 检测单位
        this.testingCompany = domain.getTestingCompany();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<ExinspPcmAcvgVO> fromDomainList(Page<ExinspPcmAcvg> domainList) {

        Page<ExinspPcmAcvgVO> list = new Page<ExinspPcmAcvgVO>();
        for (ExinspPcmAcvg exinspPcmAcvg : domainList) {
            ExinspPcmAcvgVO exinspPcmAcvgVO = new ExinspPcmAcvgVO();
            exinspPcmAcvgVO.fromDomain(exinspPcmAcvg);
            list.add(exinspPcmAcvgVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}